const { getActivityList } = require("../../../../utils/request/manage/activityManage/activityCheck")

// pages/manage/activityManage/activityCheck.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        empty: {
            show: false,
            image: 'http://ldjy.asc.jx.cn/assets/draw_fly.png'
        },
        activityList:[],
        activitySearchForm:{
            departmentId: wx.getStorageSync('departmentId'),
            stateId: 0
        },
        pager: {
            pageSize: 10,
            currentPage: 1
        }
    },

    onTabsChange(event){
        const tab = event.detail.value
        this.setData({
            'activitySearchForm.stateId': tab
        })
        this.getActivityList();
    },


    getActivityList(){
        const form = {
            pager: {
                currentPage: 1,
                pageSize: 10
            },
            searchObject: this.data.activitySearchForm
        }
        getActivityList(form).then(resp => {
            this.setData({
                activityList: resp.data
            })
        })
    },
    getMoreActivity(){
        this.setData({
            'pager.currentPage':  this.data.pager.currentPage+1,
        })
        const form = {
            pager: this.data.pager,
            searchObject: this.data.activitySearchForm
        }
        getActivityList(form).then(resp => {
            this.setData({
                activityList: this.data.activityList.concat(resp.data)
            })
        })


    },


    gotoActivityDetail(row) {
        console.log( row.currentTarget.dataset.item.activityId)
        wx.setStorageSync('activityDetailId', row.currentTarget.dataset.item.activityId);
    
        wx.navigateTo({
          url: '../activityCheckDetail/activityCheckDetail',
        })
      },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getActivityList()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        this.getActivityList()
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        console.log('触底加载')
        this.getMoreActivity()
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})